//
//  TabbarController.swift
//  SwiftDemo
//
//  Created by 宏泰财富 on 2018/11/8.
//  Copyright © 2018 宏泰财富. All rights reserved.
//

import UIKit

class TabbarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let homeVc = HomeViewController()
        addChildViewController(childController: homeVc, title: "首页", normalImg: "HomeNormal", selectImg: "HomeSelect")
        
        let myVc = MyViewController()
        addChildViewController(childController: myVc, title: "我的", normalImg: "MyNormal", selectImg: "MySelect")

    }
    
   private func addChildViewController(childController: UIViewController, title: String, normalImg: String, selectImg: String){
        let nav = NavigationController.init(rootViewController: childController)
        nav.tabBarItem = UITabBarItem.init(title: title, image: UIImage(named: normalImg)?.withRenderingMode(.alwaysOriginal), selectedImage: UIImage(named: selectImg)?.withRenderingMode(.alwaysOriginal))
        self.addChild(nav)
    }
   
}
